﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using GLImp;

namespace CastleOfTheDisillusioned.Input {
	class JoystickAxis {
		int AxisNumber;
		int Direction;
		bool Previous = false;

		public JoystickAxis(int AxisNumber, int Direction) {
			this.AxisNumber = AxisNumber;
			this.Direction = Direction;


			GraphicsManager.Update += Update;
		}

		public bool IsDown() {
			return JoystickManager.GetAxis(0, AxisNumber) == Direction;
		}

		public bool IsUp() {
			return !IsDown();
		}

		public bool IsPressed() {
			return IsDown() && !Previous;
		}

		public bool IsReleased() {
			return Previous && !IsDown();
		}

		private void Update() {
			Previous = IsDown();
		}
	}
}
